package com.lender.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lender.dao.LenderDao;
import com.lender.model.Lender;
import com.lender.service.LenderService;

@Service
@Transactional
public class LenderServiceImpl implements LenderService {
	
	@Autowired
	private LenderDao lenderDao;
	
	@Override
	public List<Lender> getLenderByParams(String name, String mobile,Integer begin,Integer end) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("lenderName", name);
		map.put("mobile", mobile);
		map.put("begin", begin);
		map.put("end", end);
		return lenderDao.getLenderByParams(map);
	}

	@Override
	public int insertLender(Lender lender) {
		
		return lenderDao.insertLender(lender);
	}

	@Override
	public int updateLender(Lender lender) {
		
		return lenderDao.updateLender(lender);
	}

	@Override
	public int getCountNum(String name, String mobile) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("lenderName", name);
		map.put("mobile", mobile);
		return lenderDao.getCountNum(map);
	}

	@Override
	public Lender getLenderById(Integer id) {
		Lender lender = lenderDao.getLenderById(id);
		if(lender !=null && lender.getId()!= null){
			return lender;
		}
		return null;
	}


}
